#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int main(int argc, char const* argv[])
{
    double boy[40], girl[40];
    int boy_num = 0, girl_num = 0;
    int n;
    scanf("%d", &n);
    char sex[5];
    double height;
    for (int i = 0; i < n; i++) {
        scanf("%s %lf", sex, &height);
        if (strcmp(sex, "male") == 0)
            boy[boy_num++] = height;
        else
            girl[girl_num++] = height;
    }
    sort(boy, boy + boy_num);
    sort(girl, girl + girl_num);

    for (int i = 0; i < boy_num; i++) {
        if (i == 0)
            printf("%.2lf", boy[i]);
        else
            printf(" %.2lf", boy[i]);
    }
    for (int i = girl_num - 1; i >= 0; i--)
        printf(" %.2lf", girl[i]);
    return 0;
}